<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Title</title>
	<script src="lib/axios.min.js"></script>
</head>
<body>
<form name="myForm">
	<p>用户名：<input type="text" name="username"></p>
	<p>密  码：<input type="password" name="password"></p>
	<p><button name="btn">登陆</button></p>
</form>
</body>
<script>
	const form = document.myForm;
	form.btn.onclick = async function(e){
		e.preventDefault();
		const username = form.username.value.trim();
		const password = form.password.value.trim();
		const {data} = await axios.post("/login",{
			username,
			password
		});
		if(data.ok === 1){
			
			localStorage.setItem("username",username);
			location.href="/info.html"
		}else{
			alert(data.msg);
		}
	}
</script>
</html>